const Sqlite3Util = appRequire('modules/Sqlite3Util');
class SysAuthSqlite3Dao{
    constructor(){

    }
    static async save(){
        let db = await Sqlite3Util.connect(appConfig.dbPath);
        await Sqlite3Util.run(db,'CREATE TABLE IF NOT EXISTS test(a int, b char)')
        await Sqlite3Util.run(db,`INSERT INTO test VALUES(?, ?)`,[1000,'thgold'])
        const response = await Sqlite3Util.all(db,'SELECT * FROM test')
        await Sqlite3Util.close(db);
    }
    static async get(){
        let db = await Sqlite3Util.connect(appConfig.dbPath);
        // let data = await Sqlite3Util.all(db,`select * from test`)
        let data = await Sqlite3Util.each(db,`select * from test`)
        await Sqlite3Util.close(db);
        return data;
    }

    static async loadMenus(){
        let db = await Sqlite3Util.connect(appConfig.dbPath);
        // let data = await Sqlite3Util.all(db,`select * from test`)
        let data = await Sqlite3Util.each(db,`select * from sys_auth`)
        await Sqlite3Util.close(db);
        return data;
    }
}
module.exports = SysAuthSqlite3Dao;